package preloader
{
	import flash.display.DisplayObject;
	import flash.display.GradientType;
	import flash.display.Sprite;
	import flash.filters.DropShadowFilter;
	import flash.geom.Matrix;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	public class PathfinderCustomPreloader extends preloader.PreloaderDisplayBase
	{
		
		
		private var t:TextField;
		private var f:DropShadowFilter=new DropShadowFilter(2,45,0x000000,0.5)
		
		private var bar:Sprite=new Sprite();
		private var barFrame:Sprite;
		private var mainColor:uint=0x00AEEF;
		private var ilosc:int=0;
		
		public function PathfinderCustomPreloader()
		{
			super();
		}
		
		
		override public function initialize():void
		{
			super.initialize();
			
			clear();  
			
			var indent:int = 20;
			var height:int = 20;
			
			
			createAssets();
		}
	
		override protected function draw():void
		{
			
			t.text = int(_fractionLoaded*100).toString()+"%";
			
			
			var d:Number=barFrame.x + barFrame.width * _fractionLoaded
			t.x = d - t.width - 25;
			
			bar.graphics.drawRoundRectComplex(0,0,400,15,12,0,0,12);
			bar.graphics.beginFill(mainColor,1);
			bar.graphics.drawRoundRectComplex(0,0,bar.width * _fractionLoaded,15,12,0,0,12);
			bar.graphics.endFill();
		}
		
		protected function createAssets():void
		{
			
			
			//craate bar
			bar = new Sprite();
			bar.graphics.drawRoundRectComplex(0,0,400,15,12,0,0,12);
			bar.x = stageWidth/2 - bar.width/2;
			bar.y = stageHeight/2 - bar.height/2;
			bar.filters = [f];
			addChild(bar);
			
			//create bar frame
			barFrame = new Sprite();
			barFrame.graphics.lineStyle(2,0xFFFFFF,1)
			barFrame.graphics.drawRoundRectComplex(0,0,400,15,12,0,0,12);
			barFrame.graphics.endFill();
			barFrame.x = stageWidth/2 - barFrame.width/2;
			barFrame.y = stageHeight/2 - barFrame.height/2;
			barFrame.filters = [f];
			addChild(barFrame);
			
			
			t = new TextField()
			t.y = barFrame.y-27;
			t.filters=[f];
			addChild(t);
			
			var s:TextFormat=new TextFormat("Verdana",null,0xFFFFFF,null,null,null,null,null,"right");
			t.defaultTextFormat=s;
		}
		
		protected function clear():void
		{    
			
		}
		
	}       
}